//
//  ErrorHandingViewController.swift
//  SwiftStudy
//
//  Created by wangtian on 15/12/23.
//  Copyright © 2015年 wangtian. All rights reserved.
//

import UIKit

enum ScoreError : Error
{
    case invalidScore
}

class ErrorHandingViewController: UIViewController {

    
    override func viewDidLoad()
    {
        super.viewDidLoad()
        do
        {
            try self.isPass(-20.0)
        }
        catch ScoreError.invalidScore
        {
            print("请输入有效的分数")
        }
        catch
        {
            
        }
    }

    func isPass(_ score:Double)throws
    {
        if score < 0.0
        {
            throw ScoreError.invalidScore
        }
        if score > 60.0
        {
            print("pass")
        }
    }
    
    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
